import { PaginatedData, PaginationResponse } from '@/types'
import { FriendSite } from '@/types/friend'
import { ROUTE_APP } from '@/lib/consts'

export async function loadFriendSite(): Promise<PaginatedData<FriendSite>> {
  try {
    const response = await fetch(`${ROUTE_APP}/friend_site`)
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`)
    }
    const data: PaginationResponse<FriendSite> = await response.json()
    return data.data
  } catch (error) {
    console.error('Error loading friend sites:', error)
    throw error
  }
}
